package demo.db.mysql.vo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * 
 * @author junying.han
 *
 */
public class RowColumn {

    private String name;

    private String type;

    private String value;

    public RowColumn() {
        super();
    }

    public RowColumn(String name, String type, String value) {
        super();
        this.name = name;
        this.type = type;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String valueStr() {
        if (value == null) {
            return "null";
        }
        if ("DATETIME".equalsIgnoreCase(type)) {
            try {
                Date date1 = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US).parse(value);
                return "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date1) + "'";
            } catch (ParseException e) {
                return "'" + value + "'";
            }
        }
        return "'" + value + "'";
    }
}
